(function() {

    angular.module('e-shop')
    
    .controller('InfoModelCtrl', InfoModelCtrl)

    .controller('ReviewImgModelCtrl', ReviewImgModelCtrl)

    .controller('EnsureModelCtrl', EnsureModelCtrl)

    .controller('TextModelCtrl', TextModelCtrl)

    EnsureModelCtrl.$inject = ['$scope', '$uibModalInstance', '$timeout', '$filter', 'item'];

    function EnsureModelCtrl($scope, $uibModalInstance, $timeout, $filter, item) {

        $scope.item = item;

        $scope.ok = function() {
            $uibModalInstance.close(true);
        };

        $scope.cancel = function() {
            $uibModalInstance.dismiss(false);
        };

    }

    ReviewImgModelCtrl.$inject = ['$scope', '$uibModalInstance', '$timeout', '$filter', 'path'];

    function ReviewImgModelCtrl($scope, $uibModalInstance, $timeout, $filter, path) {

        $timeout(function() {
            if (path.indexOf('http://7xrjgr.com1.z0.glb.clouddn.com') < 0)
                $scope.path = $filter('AuthFilter')(path);
            else
                $scope.path = path;
        }, 0, true)
        $scope.cancel = function() {
            $uibModalInstance.dismiss(false);
        };

    }

    InfoModelCtrl.$inject = ['$scope', '$uibModalInstance', '$timeout', 'info', 'type'];

    function InfoModelCtrl($scope, $uibModalInstance, $timeout, info, type) {

        $scope.type = type ? type : 'info';
        $scope.info = info;
        $timeout(function() {
            $uibModalInstance.close(true);
        }, 1500, true)
    }



    TextModelCtrl.$inject = ['$scope', '$uibModalInstance', '$timeout', 'Api'];

    function TextModelCtrl($scope, $uibModalInstance, $timeout, Api) {
        $scope.ok = function() {
            if ($scope.info)
                $uibModalInstance.close($scope.info);
            else
                $scope.hasError = false;
        };

        $scope.cancel = function() {
            $uibModalInstance.dismiss(false);
        };
    }

})();